<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
	  xmlns:th="http://www.thymeleaf.org" >
<head>
	<meta charset="utf-8">
	<title>修改密码</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/css/public.css"  media="all" />
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
</head>
<body class="childrenBody" style="margin-top: 10px">
<form class="layui-form layui-row changePwd" lay-filter="changePwd">
	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
		<div class="layui-input-block layui-red pwdTips">新密码必须两次输入一致才能提交</div>
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="hidden" th:value="${user.id}" id="userid">
				<input type="text" th:value="${user.name}" disabled class="layui-input layui-disabled">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">旧密码</label>
			<div class="layui-input-block">
				<input type="password" value="" placeholder="请输入旧密码" lay-verify="required|oldPwd" name="pwd" id="pwd" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">新密码</label>
			<div class="layui-input-block">
				<input type="password" value="" placeholder="请输入新密码" lay-verify="" name="newPwd" id="newPwd" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">确认密码</label>
			<div class="layui-input-block">
				<input type="password" value="" placeholder="请确认密码" lay-verify="" name="rightPwd" id="rightPwd" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="changePwd">立即修改</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</div>
</form>
<script src="/plugins/layui/layui.js"></script>
<script type="text/javascript" src="/common/jquery-2.1.1.js"></script>
<script type="text/javascript">
	layui.config({
		base: '/plugins/module/'
	});
	layui.use(['form','layer'],function(){
		var form = layui.form;
		var $ = layui.jquery;
		var layer = parent.layer === undefined ? layui.layer : top.layer;

			//修改密码
			form.on("submit(changePwd)",function(data){
				var userid = $('#userid').val();
				var rightPwd =  $('#rightPwd').val();
				var newPwd = $('#newPwd').val();
				if (newPwd != rightPwd){
					layer.msg("两次密码输入不一致！");
				}else {
					$.post("/staff/updatePwd?id="+userid,data.field,function(res){
						if(!res.code){
							layer.msg(res.info);

						}else {
							layer.msg(res.info);
							$('#rightPwd').val("");
							$('#newPwd').val("");
							$('#pwd').val("");
							/*setTimeout(function(){
								top.location.href="/sys/loginOut";
							},1000);*/
						}
					});
				}
				return false;
			})
	})
</script>
</body>
</html>